/*
 * 2014-03-07
 * cht
 * 主要实现对配置文件的读取
 */
package com.edais.util;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;

import org.apache.log4j.Logger;

/**
 * 主要实现对配置文件的读取
 * 
 * @author cht
 * 
 */
public class OperaterConfigFile {
	private static final Logger logger = Logger
			.getLogger(OperaterConfigFile.class);
	public static Map<String, String> map = new HashMap<String, String>();
	static {
		InputStream in = null;
		try {
			if (logger.isDebugEnabled()) {
				logger.debug("装载configExplain.properties文件");
			}
			in = logger.getClass().getClassLoader()
					.getResourceAsStream("configExplain.properties");
			Properties p = new Properties();
			p.load(new InputStreamReader(in, "UTF-8"));
			for (Object obj : p.keySet()) {
				map.put(obj.toString(), p.getProperty(obj.toString()));
			}
		} catch (FileNotFoundException e) {
			// e.
			// throw new InternalException("constants.properties文件未找到");
			logger.error("configExplain.properties文件未找到", e);
		} catch (IOException e) {
			logger.error("configExplain.properties读取错误", e);
			// throw new InternalException("constants.properties读取错误");
		} finally {
			try {
				in.close();
			} catch (IOException e) {
				logger.error("configExplain.properties文件关闭失败", e);
			}
		}
	}

	/************************ 改下为取得配置文件中的信息 *************************************/

	/***** action中的非空校验异常 ****/
	public static final String SUCCESS = map.get("success");// 操作成功
	public static final String SYSTEMERR = map.get("systemErr");// 系统错误
	public static final String PHONEISEXISTED = map.get("phone.is.existed");// 手机号已注册
	public static final String ACCESSCAPTCHAFAILED = map.get("access.captcha.failed");// 验证码发送失败
	public static final String CHECKCAPTCHAFAILED = map.get("check.captcha.failed");// 验证码校验失败
	public static final String REGISTRATIONFAILED = map.get("registration.failed");// 注册失败
	public static final String USERNOTEXIST = map.get("user.not.exist");// 用户不存在或者密码有误
	public static final String PASSWORDRESETFAILED = map.get("password.reset.failed");// 密码重置失败
	public static final String PARAMETERISNULL = map.get("parameter.is.null");// 参数为空
	public static final String GETTRADENOFAILED= map.get("get.tradeno.failed");// 交易码获取失败
	


	public static void main(String args[]) {
		// OperaterConfigFile operaterConfigFile=new OperaterConfigFile();
		System.out.println("$$$$$$$$$$$$$$$$$$=" + OperaterConfigFile.SUCCESS);
	}
}
